import java.sql.DriverManager;
import java.sql.SQLException;

import com.mysql.jdbc.Connection;


public class ConnectionUtil {
	// JDBC 驱动名及数据库 URL
    static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";  
    static final String DB_URL = "jdbc:mysql://localhost:3306/studb";
 
    // 数据库的用户名与密码，需要根据自己的设置
    static final String USER = "root";
    static final String PASS = "123456";
    static Connection conn;
	 // 注册 JDBC 驱动
    static{
    	try{
    		 Class.forName("com.mysql.jdbc.Driver");
    	}catch(ClassNotFoundException e){
    		e.printStackTrace();
    	}
    // 打开链接
    try{
    	conn = (Connection) DriverManager.getConnection(DB_URL,USER,PASS);
	}catch(SQLException e){
		e.printStackTrace();
	}
}
   
    public static java.sql.Connection getConnection(){
		return conn;
    }


}
